/**
 * @description redux-saga
 * redux常用中间件：
 * redux-logger: 日志中间件
 * redux-thunk: 异步派发中间件
 * redux-presist: 数据持久化中间件
 * redux-saga: 异步派发中间件
 */

import { createStore, applyMiddleware, compose } from 'redux'
import reducer from './reducer'
import reducerlogger from 'redux-logger'
// import thunk from 'redux-thunk'
// import reducerPromise from 'redux-promise'
import createSagaMiddleware from 'redux-saga'
import saga from './saga'


const sagaMiddleware = createSagaMiddleware() // composeEnhancers 是redux-devtools-extension的composeEnhancers
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const middleware = [reducerlogger, sagaMiddleware]
const store = createStore(reducer, composeEnhancers(applyMiddleware(...middleware)))
//运行saga
sagaMiddleware.run(saga)
export default store
